/*
 * Copyright 2007 Jeffrey Palm
 */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

final class ProgressPanel extends JPanel implements Progress {

  final JProgressBar pb = new JProgressBar();
  final JLabel lab = new JLabel("Idle...");

  ProgressPanel() {
    add(lab);
    add(pb);
  }
  
  public void update(String msg, int inc) {
    Util.note(this,inc + ":" + msg);
    pb.setString(msg);
    lab.setText(msg);
    pb.setValue(pb.getValue()+inc);
    invalidate();
    repaint();  
  }
  
  public void inc() {
    pb.setValue(pb.getValue()+1);
  }
  
  public void reset() {
    pb.setValue(0);
  }
  
  public void setMax(int max) {
    reset();
    pb.setMaximum(max);
  }
  
}